Js's [defer] and [async] properties

  • 2020-03-30 04:23:24
  • OfStack

[the defer]

Can be in < Script> By adding the defer attribute in the file to tell the browser that the script doesn't have to be executed immediately, the browser will execute the script after the document is fully loaded, which is equivalent to window.onload, but more flexible than window.onload.


 <script defer="true"></script>

[async]

Load the JavaScript using the async property so that the entire script can be loaded and executed asynchronously.

< Script> The defer attribute of the tag -- tells the browser that the script will not manipulate the DOM until the page is loaded, and that the script will be downloaded in parallel with other resource files;
< Script> The async attribute of the tag -- HTML5's new asynchronous, parallel mode where the script waits for the right time to execute the code after downloading.

Have you learned anything about the [defer] and [async] properties of javascript? If you have any questions, please leave a message to discuss with us


Related articles: